package com.codingvip.link;

/**
 * @Author Tony.Han
 * @Created at 2020/4/4 11:03 下午
 * Desc:
 */
public class MiddleNode {
    public ListNode middleNode(ListNode head) {
        if (head == null) {
            return null;
        }
        ListNode slow = head;
        ListNode fast = head;

        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }
        return slow;
    }

}
